<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * 调查
 */
class Survey extends Model
{
    use SoftDeletes;

    protected $fillable = ['user_id', 'title', 'illustration', 'type', 'counts', 'qrcode_image_url', 'start_time', 'end_time', 'direct_to'];

    /**
     * 根据调查 survey_id 获取创建者 user_id
     * 
     * @param  integer $survey_id       调查 survey_id
     * @return int|string
     */
    public static function getUserIdBySurveyId($survey_id = 0){
        return self::where(['id' => $survey_id])->value('user_id');
    }
}